//导入
const express = require('express')
//创建web服务器
const app = express()
//监听请求
app.get('/user', (req, res) => {
    res.send({
        name: '张三', age: 20, desc: '法外狂徒'
    })
})
app.get('/', (req, res) => {
    console.log(req.query);
    res.send(req.query)
})
//req.params匹配动态参数值
app.get('/user/:id', (req, res) => {
    console.log(req.params);
    res.send(req.params)
})
app.post('/user', (req, res) => {
    res.send('请求成功')
})
//启动web服务器
app.listen(8888, () => {
    console.log('localhost:8888');
})
